DEFINITION MODULE Strings;

(* (C) Copyright 1987,1988 Fitted Software Tools. All rights reserved. *)

(*
    A strings is an ARRAY OF CHAR.
    If the string does not completely fill the array, it is terminated
    by a 0C.
*)

PROCEDURE CompareStr( s1, s2 :ARRAY OF CHAR ) :INTEGER;
(*
    Returns:
        0 if s1 = s2
       -1 if s1 < s2
       +1 if s1 > s2
*)

PROCEDURE Assign( VAR source, dest :ARRAY OF CHAR );
(*
    copies source to dest
*)

PROCEDURE Length( s :ARRAY OF CHAR ) :CARDINAL;
(*
    returns the length of s
*)

PROCEDURE Concat( s1, s2 :ARRAY OF CHAR; VAR result :ARRAY OF CHAR );
(*
    Concatenates s2 to s1 and places the resulting string in result
*)

PROCEDURE Pos( subs, s :ARRAY OF CHAR ) :CARDINAL;
(*
    Returns:
        index of first occurrence of subs in s or
        > HIGH(s) if no match is found
*)

PROCEDURE Append( VAR s1 :ARRAY OF CHAR; s2 :ARRAY OF CHAR );
(*
    appends s2 at the end of s1.
    equivalent to Concat( s1, s2, s1 ), but more obvious and efficient.
*)

PROCEDURE Insert( subs :ARRAY OF CHAR; VAR s :ARRAY OF CHAR; at :CARDINAL );
(*
    inserts subs into s at position at.
*)

PROCEDURE Delete( VAR s :ARRAY OF CHAR; pos, len :CARDINAL );
(*
    delete len chars from s starting at position pos
*)

PROCEDURE Copy( src :ARRAY OF CHAR; pos, len :CARDINAL;
                VAR dest :ARRAY OF CHAR );
(*
    copy len characters starting at pos from src to dest
*)

END Strings.